﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>销售报价单</title>
<link rel="stylesheet" type="text/css"
	href="../extjs/resources/css/ext-all.css" />
<script type="text/javascript" src="../extjs/ext-all.js"></script>
<script type="text/javascript" src="../extjs/ext-lang-zh_CN.js"></script>

<script>
 Ext.onReady(function(){
//Ext.BLANK_IMAGE_URL = "extjs/resources/images/default/s.gif";
	  Ext.QuickTips.init();
	  windowst.show();  
	  findAll(1) ;
});
 var store1 = Ext.data.JsonStore({
		fields : []	
	}); 
 var store2 = Ext.data.JsonStore({
		fields : []	
	});
 var store3 = Ext.data.JsonStore({
		fields : []	
	});
 var store4 = Ext.data.JsonStore({
		fields : []	
	});
 var store5 = Ext.data.JsonStore({
		fields : []	
	}); 
 
var fielmenu=new Ext.menu.Menu({
	items:[{text:'历史交易查询',handler:function(){
		querylsjy();		
	}},{text:'利润预估查询',handler:function(){
		querylryg();		
	}}]
	});
	var fielmenu3=new Ext.menu.Menu({
		items:[{text:'审核',handler:function(){
			shenhe();
		}},{text:'反审核',handler:function(){
			fanshenhe();
		}}]
	});
	
	//未税的方法
	function jisuan(){
		var zongjine=0.00;
		Ext.each(Ext.pluck(grids.getStore().data.items,'data'), function(obj,i) {  
			var number=0;   //数量
			var jine=0.00;	//金额
			var price=0.00;	//单价
			var shuie=0.00;  //税额
			var shuilv=17;	//税率
			var hsjine=0.00; //含税金额
			var zheqian=0.00;  //折扣前金额
			var zheshu=100;		//折数
				number=obj.sumqty;  //数量=编辑的grid中的数量
				zheqian=obj.beforemoney; //折前单价
				price=obj.price;
				jine=(number*price);
				zheshu=(jine/zheqian/number)*100;
				shuie=(parseInt(jine*shuilv)/100);
				hsjine=(jine+shuie);
				grids.store.getAt(i).set('money',jine)  ;
				grids.store.getAt(i).set('taxmoney',shuie);
				grids.store.getAt(i).set('sumtax',hsjine);
				grids.store.getAt(i).set('zheshu',zheshu);
				zongjine+=hsjine;				
	    });
		Ext.getCmp('zongjine').setValue(zongjine);
	      
		 
	}
 	//含税的方法
	function jisuan2(){
		var zongjine2=0.00;
		Ext.each(Ext.pluck(grids.getStore().data.items,'data'), function(obj,i) {  
			var number=0;   //数量
			var jine=0.00;	//金额
			var price=0.00;	//单价
			var shuie=0.00;  //税额
			var shuilv=17;		 //税率
			var hsjine=0.00; //含税金额
			var zheqian=0.00;  //折扣前金额
			var zheshu=100;		//折数
			    number=obj.sumqty;
				price=obj.price*(1+0.17);
				hsjine=(number*price);
				jine=hsjine/(1+0.17);
				shuie=hsjine-jine;
				zheqian=obj.beforemoney; 			
			    zheshu=(jine/zheqian/number)*100;
				grids.store.getAt(i).set('money',jine)  ;
				grids.store.getAt(i).set('taxmoney',shuie);
				grids.store.getAt(i).set('sumtax',hsjine);
				grids.store.getAt(i).set('zheshu',zheshu);
				grids.store.getAt(i).set('price',price);
				zongjine2+=hsjine; 					
	    });
		Ext.getCmp('zongjine').setValue(zongjine2);		 
	}
		 	   
var grids=Ext.create('Ext.grid.Panel',{   
	 listeners:{
				containerdblclick: function(grid, e, eOpts){ //单击事件
	    						grid.getStore().add({'prodId':'', 'proname':'','sumqty':'0.0','beforemoney':'0.0','zheshu':'100',
	    							'price':'0.0','money':'0.0','taxlv':'0.0','taxmoney':'0.0','sumtax':'0.0','ispresent':'n','remark':''});   						
    					},'edit':function(){
    						var zt=Ext.getCmp('priceoftax').getValue();
    						if(zt=="未税"){
    							jisuan();
    						}else{
    							 jisuan2();
    						}						
    					    }				
			},plugins: [
        				Ext.create('Ext.grid.plugin.CellEditing', {
            				clicksToEdit: 1
        				})
    				],
	columns: [
				 {header: '（栏号）',
	                    		xtype: 'rownumberer',
	                    		dataIndex: 'lh', 
	                    		width: 80,
								sortable: false
        					},
					
        		{ header: '物料编号',  dataIndex: 'prodId', width: 120,editor: { xtype:'textfield',
				 	listeners:{
				 		specialkey:function(grid,e,eOpts){
			                if (e.getKey()==Ext.EventObject.ENTER){               	 
			                	cxwll();             	
			                }
			            }			 		
					}}},
       			     { header: '物料名称', dataIndex: 'proname',width: 120},
					 { header: '数量', dataIndex: 'sumqty',width: 120,editor: { xtype:'textfield'}},
					 { header: '折扣前单价', dataIndex: 'beforemoney',width: 120 },
					 { header: '折数(%)', dataIndex: 'zheshu' ,width: 120},
					 { header: '单价', dataIndex: 'price' ,width: 120,editor: { xtype:'textfield'}},
					 { header: '金额', dataIndex: 'money' ,width: 120},
					 { header: '税率', dataIndex: 'taxlv',width: 120},
					 { header: '税额', dataIndex: 'taxmoney' ,width: 120},
					 { header: '含税金额', dataIndex: 'sumtax' ,width: 120,editor: { xtype:'textfield'}},
					 { header: '赠品', dataIndex: 'ispresent' ,width: 120},
					 { header: '分录备注', dataIndex: 'remark' ,width: 120}				
   					 ],
   			 store:store1,
   			 height: 130,
			 width:1971,
			 autoScroll:false,
			 
})

var filterPanel = Ext.create('Ext.panel.Panel', {
    bodyPadding: 6,  // 避免Panel中的子元素紧邻边框
    width: 1985,
	height:170,
    items:[grids],
	bbar:[{xtype:"label",text:'总计:',width:90},
	{xtype:"textfield",disabled:true,width:90,margin:'0 200 0 200',value:'0.00',id:'zongjine'}]
});

var  tableds=Ext.create('Ext.TabPanel',{
	width:"100%",
	height:230,
	autoScroll:true,
	bodyPadding: 5,
	items:[{title:'内容',autoScroll:true,items:[filterPanel]},{title:'备注',xtype:'textarea',name:'Remark',fieldLabel: '备注',labelWidth: 30,}],
});


var formsg=Ext.create('Ext.form.Panel', {
    bodyPadding: 5,
	height:'100%',
	layout:"column",
	baseCls:'x-plain',
	items:[{
		
		xtype: 'textfield',
        name: 'salesId',
        id:'salesId',
		bodyPadding: 5,
        fieldLabel: '业务人员',
		width:250,
        labelWidth: 80,
        anchor: '100%',
			},{
		
		xtype: 'textfield',
        name: 'maker',
        id:'maker',
        fieldLabel: '制单人员',
		style:'margin-left:19px',
		width:250,
        labelWidth: 80,
        anchor: '100%',
			},{
		
		xtype: 'textfield',
        name: 'departId',
        id:'departId',
        fieldLabel: '所属部门',
		width:250,
        labelWidth: 80,
        anchor: '100%',
			},{
		
		xtype: 'textfield',
        name: 'permitter',
        id:'permitter',
        fieldLabel: '复核人员',
		style:'margin-left:19px',
		width:250,
        labelWidth: 80,
        anchor: '100%',
			}],
	});




var forms=Ext.create('Ext.form.Panel', {
    bodyPadding: 5,
	height:'100%',
	layout:"column",
	baseCls:'x-plain',
	items:[
	{
			xtype: 'checkbox', //多行文本域
			id:'zskh',
        	name: 'fapiaoshifou',
			hideLabels:true,
			checkboxToggle:true,
	},
	  {
		style:"margin-left:5px",
		xtype: 'textfield',
		id:'customerId',
        name: 'customerId',
        fieldLabel: '正式客户',
		width:250,
        labelWidth: 80,
		emptyText:'请输入客户',
        anchor: '100%',
        listeners:{
            specialkey:function(field,e){
                if (e.getKey()==Ext.EventObject.ENTER){               	 
                	cxkhh();               	
                }
            }
        }},
	   {
		style:'margin-left:9px;color:blue',
		xtype: 'datefield',		 
        name: 'billdate',
        fieldLabel: '单据日期',
        id:'billdate',
		width:250,
        labelWidth: 70,
        anchor: '100%',
        listeners: 
        {
            //添加日期选择事件
          "select": function (field,value) 
          {
        	  datess();
          }
        },
        format:'Y-m-d',
			},{
		style:'margin-left:18px',
		 xtype: 'textfield',
		id:'addressId',
        name: 'addressId',
        fieldLabel: '送货地址',
		width:150,
        labelWidth: 80,
        anchor: '100%', 
			},{
		xtype: 'textfield',
        name: 'dizhiton',
		width:99,
        labelWidth: 70,
		margin:"0 1",
        anchor: '100%',
			},{
			style:'margin-left:9px',
		 xtype: 'textfield',
		 id:'billno',
        name: 'billno',
		style:"color:blue;margin-left:9px",
        fieldLabel: '单据号码',
		width:250,
        labelWidth: 70,
        anchor: '100%',
			},{
		style:'margin-left:18px;color:blue',
		xtype: 'datefield',
        name: 'validdate',
        id:'validdate',
        fieldLabel: '有效日期',		
		width:250,
		format:'Y-m-d',
        labelWidth: 80,
        anchor: '100%',
			},{
		style:'margin-left:9px',
		xtype: 'textfield', //多行文本域
        name: 'MoneyStyle',
        id:'MoneyStyle',
        fieldLabel: '币别',
        labelWidth: 70,
		width:250,
        anchor: '100%',
			},{
				    style:'margin-left:18px',
	             	fieldLabel: '单价是否含税',
					xtype:'combo',
	             	name: 'priceoftax',
	             	id:'priceoftax',
	             	displayField: 'name',
					labelWidth:80,
					width:250,
    				valueField: 'abbr',
					store: Ext.create('Ext.data.Store', {
						fields: ['abbr', 'name'],
    					data : [
        					{"abbr":"含税", "name":"含税"},
        					{"abbr":"未税", "name":"未税"}
							
					   ]
					}),
					 listeners:{
			            select:function(field,e){
			            	if(Ext.getCmp('priceoftax').getRawValue() == '未税'){
			            		jisuan();
			            	}else{
			            		jisuan2();	
			            	}
			            	
			            }
			        }, 
					value: '含税',
        			typeAhead: true,
        			mode: 'local',
        			triggerAction: 'all',
        			selectOnFocus:true,
        			
	         	},{
			style:'margin-left:9px',
		 xtype: 'textfield', //多行文本域
        name: 'exchrate',
        id:'exchrate',
        fieldLabel: '汇率',
        labelWidth: 70,
		width:250,
        anchor: '100%',
			},tableds,formsg
	]
    
	
	
});

//winform窗口
	var windowst=new  Ext.Window({
		width:660,
		height:480,
		title:"销售报价单",
		closable:true,
		resizable:false, //设置是否可以改变大小
		draggable:true,
		anchor: '100%',
		items:[forms],
		bbar:[{xtype:"splitbutton",text:'查询',width:90,menu:fielmenu},
		{xtype:"splitbutton",text:'功能',width:90,menu:fielmenu3},
		{xtype:"button",text:'新建',width:90,
			listeners: { "click": function () {
				newpro();
	         }
	    }},
		{xtype:"button",text:'保存',width:90,
			listeners: { "click": function () {
				adds();
	         }
	    }},{xtype:"button",text:'删除',width:90,
			listeners: { "click": function () {
				deletes();
	         }
	    }},{xtype:"button",text:'上一页',width:90,
			listeners: { "click": function () {
				syy();
	         }
	    }},{xtype:"button",text:'下一页',width:90,
			listeners: { "click": function () {
				xyy();
	         }
	    }}],
	});
	 	
	    var ss=null;
	//分页查询
     	function findAll(num) {
 		Ext.Ajax.request({
			//被用来向服务器发起请求默认的url  
			url : "/xs/querybypage",
			//请求时发送后台的参数,既可以是Json对象，也可以直接使用“name = value”形式的字符串  
			params : {pagenum:num},
			//请求时使用的默认的http方法  
			method : "post",
			//请求成功时回调函数  
			success : function(data) {
			ss=Ext.JSON.decode(data.responseText);	
				Ext.getCmp('billno').setValue(ss.pagedata[0].billno);
				Ext.getCmp('billdate').setValue(ss.pagedata[0].billdate);
				Ext.getCmp('customerId').setValue(ss.pagedata[0].customerId);
				Ext.getCmp('addressId').setValue(ss.pagedata[0].addressId);
				Ext.getCmp('validdate').setValue(ss.pagedata[0].validdate);
				Ext.getCmp('priceoftax').setValue(ss.pagedata[0].priceoftax);
				Ext.getCmp('exchrate').setValue(ss.pagedata[0].exchrate);
				Ext.getCmp('salesId').setValue(ss.pagedata[0].salesId);
				Ext.getCmp('departId').setValue(ss.pagedata[0].departId);
				Ext.getCmp('maker').setValue(ss.pagedata[0].maker);
				Ext.getCmp('permitter').setValue(ss.pagedata[0].permitter);
				Ext.getCmp('MoneyStyle').setValue('人民币'); 
			    grids.getStore().loadData(ss.pagedata[0].bjinfos);
			},
			//请求失败时回调函数  
			failure : function() {
				Ext.ux.Toast.msg("信息提示", "信息出错，请联系管理员!");
			}
 		 
		  });
	 }  
     	//新增方法
    	function adds(){
    	if(Ext.getCmp('validdate').getValue()==null){
    		Ext.Msg.alert('提示','有效日期为必填项');
    		return;
    	}	    		
    	else{
    		 var kk=grids.getStore();
    		 var ss={};
    		 ss["billno"]=Ext.getCmp('billno').getValue();
    		 ss["billdate"]=Ext.getCmp('billdate').getValue();
    		 ss["customerId"]=Ext.getCmp('customerId').getValue();
    		 ss["addressId"]=Ext.getCmp('addressId').getValue();
    		 ss["validdate"]=Ext.getCmp('validdate').getValue();
    		 ss["priceoftax"]=Ext.getCmp('priceoftax').getValue();
    		 ss["exchrate"]=Ext.getCmp('exchrate').getValue();
    		 ss["salesId"]=Ext.getCmp('salesId').getValue();
    		 ss["departId"]=Ext.getCmp('departId').getValue();
    		 ss["maker"]=Ext.getCmp('maker').getValue();
    		 ss["permitter"]=Ext.getCmp('permitter').getValue();
    		 ss["totalmoney"]=Ext.getCmp('zongjine').getValue();
    		 ss["MoneyStyle"]=Ext.getCmp('MoneyStyle').getValue();
    		 var str=Ext.pluck(kk.data.items,'data');
    		 ss["bjinfo"]=str;
    		 Ext.Ajax.request({
    				url : "/xs/addbj",
    				params : {bj:JSON.stringify(ss)},
    				method : "post",
    				success : function(data) {
    					 Ext.Msg.alert('提示',data.responseText);
    				},
    				failure : function() {
    					
    				}
    	 		 
    			  }); 		 	
    	}	
    		 
	    }
    	//上一页
    	function syy(){
    		if(ss.pagenum==1){
    			Ext.Msg.alert('提示','没有上一页了');
    			return;
    		}else{
    			findAll(ss.previouspage);
    		}		
    	}
    	//下一页
    	function xyy(){
    		if(ss.pagenum==ss.maxpage){
    			Ext.Msg.alert('提示','没有下一页了');
    			return;
    		}else{
    			findAll(ss.nextpage);
    		}		
    	}
    	//删除主详表
    	function deletes(){
    		var billno=Ext.getCmp('billno').getValue();
    		 Ext.Ajax.request({
 				url : "/xs/deletebj",
 				params : {bno:billno},
 				method : "post",
 				success : function(data) {
 					 Ext.Msg.alert('提示',data.responseText);
 				 findAll(ss.previouspage);
 				},
 				failure : function() {					
 				}
 	 		 
 			  }); 	
    	}
    	function newpro(){
			Ext.getCmp('billdate').setValue(new Date());
			Ext.getCmp('customerId').setValue('');
			Ext.getCmp('addressId').setValue('');
			Ext.getCmp('validdate').setValue('');
			Ext.getCmp('priceoftax').setValue('含税');
			Ext.getCmp('exchrate').setValue('1');
			Ext.getCmp('salesId').setValue('');
			Ext.getCmp('departId').setValue('');
			Ext.getCmp('maker').setValue('张制单');
			Ext.getCmp('permitter').setValue('');
			Ext.getCmp('MoneyStyle').setValue('人民币'); 
			grids.getStore().loadData('');
			datess();			
    	}
    	
    	//日期的改变事件
    	function datess(){
    		Ext.Ajax.request({
				url : "/xs/querymax",
				params : {dd:Ext.getCmp('billdate').getValue()},
				method : "post",
				success : function(data) {
					Ext.getCmp('billno').setValue(data.responseText);
				},
				failure : function() {
					
				}
	 		 
			  }); 	
    	}
    	
   	
    	//客户加载带出人员以及部门事件
    	function cxkhh(){
    		var grids3=Ext.create('Ext.grid.Panel',{   
        		columns: [
        					 {header: '（栏号）',
        		                    		xtype: 'rownumberer',
        		                    		dataIndex: 'lh', 
        		                    		width: 80,
        									sortable: false
        	        					},
        	        			 { header: '客户编号',  dataIndex: 'fullid', width: 120},
        	        			 { header: '客户简称',  dataIndex: 'fullname', width: 120}	
        	   					 ],
        	   			 store:store3,
        	   			 height: 260,
        				 width:400,
        				 autoScroll:true,				 
        	})
        	
        var btn=Ext.create("Ext.Button", {
            text: "取回",
            listeners: { "click": function () {  
                       
               if(grids3.getSelectionModel().getCount()==0){
                	 Ext.Msg.alert("提示信息", "您没有选中行!");  
                	 return;
                }else{
                	 var selectedData=grids3.getSelectionModel().getSelection()[0].data;
            		 Ext.Ajax.request({ 
							url : "/xs/querycustbyid",
							params : {cid:selectedData.fullid},
							method : "post",
							success : function(data) {
								var ll=Ext.JSON.decode(data.responseText);
								Ext.getCmp('customerId').setValue(ll.fullname);
								Ext.getCmp('salesId').setValue(ll.personnelname);
								Ext.getCmp('departId').setValue(ll.deptname);
								win.close();  
							},
							failure : function() {
								
							}				 		 
						  });     
                     }
                }
            },
            id: "btn",
        });	
    		
    	var win=Ext.create('Ext.window.Window', {  
	                id:'khWindow',             
	                title: '客户',  
	                width:420,
					height:310,  
					items:[btn,grids3],
					closeAction: 'destroy',
					 listeners: {
						 activate : function() {							    	      
							 Ext.Ajax.request({ 
									url : "/xs/querycust",
									params : {},
									method : "post",
									success : function(data) {
										var mm=Ext.JSON.decode(data.responseText);
										grids3.getStore().loadData(mm);
									},
									failure : function() {
										
									}
						 		 
								  }); 	 						 
				     }
			      } 	  					   
	            }).show();     		
    	}
    	
    	
    	//查询物料并加载到grid中
    	function cxwll(){
    		var grids4=Ext.create('Ext.grid.Panel',{   
        		columns: [
        					 {header: '（栏号）',
        		                    		xtype: 'rownumberer',
        		                    		dataIndex: 'lh', 
        		                    		width: 80,
        									sortable: false
        	        					},
        	        			 { header: '物料编号',  dataIndex: 'prodId', width: 120},
        	        			 { header: '物料名称',  dataIndex: 'prodName', width: 120}	
        	   					 ],
        	   			 store:store4,
        	   			 height: 260,
        				 width:400,
        				 autoScroll:true,				 
        	})
        	
        var btn3=Ext.create("Ext.Button", {
            text: "取回",
            listeners: { "click": function () {  
                       
               if(grids4.getSelectionModel().getCount()==0){
                	 Ext.Msg.alert("提示信息", "您没有选中行!");  
                	 return;
                }else{
                	 var selectedData=grids4.getSelectionModel().getSelection()[0].data;
            		 Ext.Ajax.request({ 
							url : "/xs/querymatbyidss",
							params : {mid:selectedData.prodId},
							method : "post",
							success : function(data) {
								var nn=Ext.JSON.decode(data.responseText);	   
							    grids.getSelectionModel().getSelection()[0].set("prodId",nn.prodId);  
							    grids.getSelectionModel().getSelection()[0].set("proname",nn.proname); 
							    grids.getSelectionModel().getSelection()[0].set("beforemoney",nn.beforemoney); 
							    grids.getSelectionModel().getSelection()[0].set("zheshu",nn.zheshu); 
							    grids.getSelectionModel().getSelection()[0].set("price",nn.price); 
							    grids.getSelectionModel().getSelection()[0].set("taxlv",nn.taxlv); 
								win2.close();
							},
							failure : function() {
								
							}				 		 
						  });     
                     }
                }
            },
            id: "btn3",
        });	
    	//查询物料	
    	var win2=Ext.create('Ext.window.Window', {  
	                id:'wlWindow',             
	                title: '选择物料',  
	                width:420,
					height:310,  
					items:[btn3,grids4],
					closeAction: 'destroy',
					 listeners: {
						 activate : function() {							    	      
							 Ext.Ajax.request({ 
									url : "/xs/querymater",
									params : {},
									method : "post",
									success : function(data) {
										var mm=Ext.JSON.decode(data.responseText);
										grids4.getStore().loadData(mm);
									},
									failure : function() {
										
									}
						 		 
								  }); 	 						 
				     }
			      } 	  					   
	            }).show();     		
    	}	
    	
    	
    	
	
    	//历史交易查询
    	 function querylsjy(){	 
    		 var grids2=Ext.create('Ext.grid.Panel',{   
    	    		columns: [
    	    					 {header: '（栏号）',
    	    		                    		xtype: 'rownumberer',
    	    		                    		dataIndex: 'lh', 
    	    		                    		width: 60,
    	    									sortable: false
    	    	        					},
    	    	        			 { header: '单别',  dataIndex: 'danbie', width: 120}, 	        			
    	    	        			 { header: '单号',  dataIndex: 'billno', width: 120},
    	    	        			 { header: '币别',  dataIndex: 'bibie', width: 120},
    	    	        			 { header: '汇率',  dataIndex: 'exchrate', width: 120},
    	    	        		     { header: '物料编号',  dataIndex: 'prodId', width: 120},
    	    	       			     { header: '物料名称', dataIndex: 'proname',width: 120},
    	    						 { header: '数量', dataIndex: 'sumqty',width: 120},
    	    						 { header: '折扣前单价', dataIndex: 'beforemoney',width: 120 },
    	    						 { header: '折数(%)', dataIndex: 'zheshu' ,width: 120},
    	    						 { header: '单价', dataIndex: 'price' ,width: 120},
    	    						 { header: '单价是否含税', dataIndex: 'priceoftax' ,width: 120},
    	    						 { header: '金额', dataIndex: 'money' ,width: 120},
    	    						 { header: '备注', dataIndex: 'remark' ,width: 120},
    	    						 { header: '日期',  dataIndex: 'dates', width: 120},
    	    						 { header: '税率', dataIndex: 'taxlv',width: 120 },
    	    						 { header: '税额', dataIndex: 'taxmoney' ,width: 120},
    	    						 { header: '含税金额', dataIndex: 'sumtax' ,width: 120}
    	    	   					 ],
    	    	   			 store:store2,
    	    	   			 height: 360,
    	    				 width:760,
    	    				// singleSelect:false,
    	    				 autoScroll:true,				 
    	    	})
    	    	
    	   var btn2=Ext.create("Ext.Button", {
            text: "取回",
            listeners: { "click": function () {  
                       
               if(grids2.getSelectionModel().getCount()==0){
                	 Ext.Msg.alert("提示信息", "您没有选中行!");  
                	 return;
                }else{              
                	 var rows = grids2.getView().getSelectionModel().getSelection();      
                     grids.getStore().add(rows[0].data);
                     lsjy.close();                                                          
                 }
                }
            },
            id: "btn2",
        });	
    	    	   		 		        
    		       var lsjy=Ext.create('Ext.window.Window', {  
    		                id:'myWindow',             
    		                title: '历史交易查询',  
    		                width:680,
    						height:420,  
    		                closeAction: 'destroy',
    		                items:[btn2,grids2],
    		                listeners: {
    							 activate : function() {
    								 grids2.getStore().removeAll();   								 
    								 Ext.Ajax.request({ 
    										url : "/xs/querybycust",
    										params : {cust:Ext.getCmp('customerId').getValue()},
    										method : "post",
    										success : function(data) {
    											var oo=Ext.JSON.decode(data.responseText);
    											 grids2.getStore().add(oo);
    										},
    										failure : function() {
    											
    										}
    							 		 
    									  }); 
    								 Ext.Ajax.request({ 
 										url : "/xs/querybycust2",
 										params : {cust:Ext.getCmp('customerId').getValue()},
 										method : "post",
 										success : function(data) {
 											var bb=Ext.JSON.decode(data.responseText);
 											grids2.getStore().add(bb);
 										},
 										failure : function() {
 											
 										}
 							 		 
 									  });  
    								 Ext.Ajax.request({ 
  										url : "/xs/querybycust3",
  										params : {cust:Ext.getCmp('customerId').getValue()},
  										method : "post",
  										success : function(data) {
  											var aa=Ext.JSON.decode(data.responseText);
  											grids2.getStore().add(aa);
  										},
  										failure : function() {
  											
  										}
  							 		 
  									  });    								 
    					     }
    				      }  
    		            
    		            }).show();  
    		       	        
    	} 
    	function　querylryg(){
    		var grids5=Ext.create('Ext.grid.Panel',{   
	    		columns: [
	    					 {header: '（栏号）',
	    		                    		xtype: 'rownumberer',
	    		                    		dataIndex: 'lh', 
	    		                    		width: 60,
	    									sortable: false
	    	        					},
	    	        		     { header: '物料编号',  dataIndex: 'prodId', width: 120},
	    	       			     { header: '物料名称', dataIndex: 'proname',width: 120},
	    						 { header: '本币金额', dataIndex: 'bbje' ,width: 120},
	    						 { header: '实际成本', dataIndex: 'sjcb' ,width: 120},
	    						 { header: '实际毛利',  dataIndex: 'sjml', width: 120},
	    						 { header: '实际毛利率', dataIndex: 'sjmlv',width: 120 },
	    						 { header: '标准成本', dataIndex: 'bzcb' ,width: 120},
	    						 { header: '标准毛利', dataIndex: 'bzml' ,width: 120},
	    						 { header: '标准毛利率', dataIndex: 'bzmlv' ,width: 120}
	    	   					 ],
	    	   			 store:store5,
	    	   			 height: 360,
	    				 width:760,
	    				 autoScroll:true,				 
	    	})
	    	
		        
		       var lryg=Ext.create('Ext.window.Window', {  
		                id:'myWindow',             
		                title: '利润预估查询',  
		                width:750,
						height:420,  
		                closeAction: 'destroy',
		                items:[grids5],
		                listeners: {
							 activate : function() {
								 Ext.Ajax.request({ 
										url : "/xs/querybybills",
										params : {bill:Ext.getCmp('billno').getValue()},
										method : "post",
										success : function(data) {
											var aa=Ext.JSON.decode(data.responseText);
											grids5.getStore().loadData(aa);
										},
										failure : function() {
											
										}
							 		 
									  });    							 								 		 
					     }
				      }  
		            
		            }).show();  
	    	    		
    	}
    	
    	
    	function　shenhe(){
    		 Ext.Ajax.request({ 
					url : "/xs/bjsh",
					params : {bno:Ext.getCmp('billno').getValue()},
					method : "post",
					success : function(data) {
						 Ext.Msg.alert("提示信息",data.responseText); 
					},
					failure : function() {
						
					}
		 		 
				  });  
    	}
    	function　fanshenhe(){
    		Ext.Ajax.request({ 
				url : "/xs/bjfsh",
				params : {bno:Ext.getCmp('billno').getValue()},
				method : "post",
				success : function(data) {
					 Ext.Msg.alert("提示信息",data.responseText); 
				},
				failure : function() {
					
				}
	 		 
			  });  
    	}
    	
    	
</script>
</head>

<body>
</body>
</html>